//
//  RequirementTableViewCell.m
//  SsehMaster
//
//  Created by 杨阳 on 2018/8/9.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "RequirementTableViewCell.h"
#import "NSString+BRSize.h"

@interface RequirementTableViewCell()


@property (weak, nonatomic) IBOutlet UIView *leftItemView;
@property (weak, nonatomic) IBOutlet UIView *rightItemView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *leftItemWidth;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightItemWidth;

@end

@implementation RequirementTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

-(void)configData:(NSString *)tipStr{
    
    NSArray * tipsArr = [tipStr componentsSeparatedByString:@","];
    
    switch (tipsArr.count) {
        case 0:
            self.leftItemView.hidden = YES;
            self.rightItemView.hidden = YES;
            self.bottomLabel.hidden = YES;
            self.bottomLabelHeight.constant = 0;
            break;
        case 1:
            self.leftItemView.hidden = NO;
            self.rightItemView.hidden = YES;
            self.leftItemWidth.constant = VIEW_WIDTH;
            self.rightItemWidth.constant = 0;
            self.bottomLabel.hidden = YES;
            self.bottomLabelHeight.constant = 0;
            break;
        case 2:
            self.leftItemView.hidden = NO;
            self.rightItemView.hidden = NO;
            self.leftItemWidth.constant = VIEW_WIDTH/2;
            self.rightItemWidth.constant = VIEW_WIDTH/2;
            self.bottomLabel.hidden = YES;
            self.bottomLabelHeight.constant = 0;
            break;
        case 3:
            self.leftItemView.hidden = NO;
            self.rightItemView.hidden = NO;
            self.leftItemWidth.constant = VIEW_WIDTH/2;
            self.rightItemWidth.constant = VIEW_WIDTH/2;
            self.bottomLabel.hidden = NO;
            break;
            
        default:
            break;
    }
    NSString * string;
    CGFloat height = 0.0f;
    for (NSInteger i = 0; i < tipsArr.count; i++) {
        switch (i) {
            case 0:
                self.leftLabel.text = tipsArr[i];
                break;
            case 1:
                self.rightLabel.text = tipsArr[i];
                break;
            case 2:
                string = [NSString stringWithFormat:@"%@",tipsArr[i]];
                height = [string heightWithFont:[UIFont systemFontOfSize:16] constrainedToWidth:VIEW_WIDTH-20];
                self.bottomLabelHeight.constant = height+20;
                self.bottomLabel.text = string;
                break;
                
            default:
                break;
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
